package com.kaikeba.estack.web.controller;

import com.kaikeba.estack.bean.Message;
import com.kaikeba.estack.bean.User;
import com.kaikeba.estack.service.UserService;
import com.kaikeba.estack.web.dto.PageDto;
import com.kaikeba.estack.web.mvc.Controller;
import com.kaikeba.estack.web.mvc.RequestBody;
import com.kaikeba.estack.web.mvc.RequestMapping;
import com.kaikeba.estack.web.mvc.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * 管理员页面用户操作相关接口
 *
 * @Auth xingwan
 * @Date 2020/10/2 23:53
 **/
@Controller
@RequestMapping("/admin/user")
public class UserController {

    @RequestMapping("/list")
    public Message<PageDto<User>> list(HttpServletRequest request, @RequestBody PageDto pageDto) {
        return Message.ok(UserService.queryCourierByPage(pageDto));
    }

    /**
     * 根据条件查询用户存在不存在
     *
     * @param key
     * @param value
     * @return
     */
    @RequestMapping("/exists")
    public Message<PageDto<User>> username(@RequestParam("key") String key, @RequestParam("value") String value) {
        return Message.ok(UserService.queryExists(key, value) != null);
    }

}
